<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/base/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/base/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/base/public.css" />
		<script src="js/base/av-min-2.1.2.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/base/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>

	</head>
	<style type="text/css">
		.personal_centerTop {
			position: fixed;
			top: 0px;
			height: 50px;
			width: 100%;
			display: -webkit-box;
		}
		
		.top_fanhui {
			width: 50px;
			font-size: 20px;
			text-align: center;
			line-height: 50px;
			color: #FFF;
		}
		
		.top_name {
			-webkit-box-flex: 1;
			font-size: 18px;
			line-height: 50px;
			color: #FFF;
		}
		
		.content {
			padding: 50px 0px;
		}
		
		.contentLogo {
			border: 1px solid #ddd;
			height: 20vh;
			width: 100%;
		}
		
		.logoTxt {
			margin-top: 20px;
			color: #666;
			font-weight: bolder;
			text-indent: 1em;
			font-size: 26px;
		}
		
		.payChoice {
			border-bottom: 1px solid #E5E5E5;
			overflow: auto;
		}
		
		.payChoice div {
			border: 1px solid #E5E5E5;
			width: 100px;
			text-align: center;
			float: right;
			padding: 10px;
		}
		
		.payChoice div:first-child {
			/*margin-right: 30px;*/
		}
		
		.payChoiceHui {
			font-size: 42px;
		}
		
		#guanggao div {
			border: 1px solid rgba(234, 234, 234, 1);
			border-radius: 20px;
			height: 150px;
			margin: 20px;
			background-size: cover;
		}
		
		.guanggao1 {
			background-image: url(img/index/guanggao2.jpg);
			background-position-y: -20px;
		}
		
		.guanggao2 {
			background-image: url(img/index/guanggao1.jpg);
			background-position-y: -70px;
		}
	</style>

	<body>
		<div class="personal_centerTop top_blue">
			<div class="top_fanhui Hui-iconfont Hui-iconfont-slider-left"></div>
			<div class="top_name font-weight">结算信息</div>
		</div>

		<!--内容开始-->
		<div class="content">
			<div class="contentLogo">
				<div class="logoTxt">本次需支付 <span class="moneyNum">0</span>.00元</div>
			</div>
			<div class="payChoice">
				<div id="zhifubao">
					<span style="color: rgba(89,170,225,1);" class="payChoiceHui Hui-iconfont Hui-iconfont-pay-alipay-1"></span><br />支付宝支付
				</div>
				<div id="weixin">
					<span style="color: rgba(0,200,0,1);" class="payChoiceHui Hui-iconfont Hui-iconfont-pay-weixin"></span><br />微信支付
				</div>
			</div>
			<div style="clear: both;" id="guanggao">
				<div class="guanggao1"></div>
				<div class="guanggao2"></div>
			</div>
		</div>
		<!--内容结束-->

		<!--底部按钮开始-->
		<div class="weui-tabbar footer">
			<a href="index.html" class="weui-tabbar__item ">
				<p class="footertab_blue weui-tabbar__label Hui-iconfont Hui-iconfont-saoyisao "></p>
			</a>
			<a href="IM.html " class="weui-tabbar__item ">
				<p class="weui-tabbar__label Hui-iconfont Hui-iconfont-xiaoxi1 "></p>
			</a>
			<a href="personal.html " class="weui-tabbar__item ">
				<p class=" weui-tabbar__label Hui-iconfont Hui-iconfont-user "></p>
			</a>
		</div>
		<!--底部按钮结束-->
	</body>

	<script type="text/javascript">
		window.onload = function() {
			//接入leanCloud初始化开始
			var APP_ID = 'hN1kSQf2DQ9awcJmwEmIIdVo-gzGzoHsz';
			var APP_KEY = 'aHCVjhhcyeerTEsKObkGSyd6';
			AV.init({
				appId: APP_ID,
				appKey: APP_KEY
			});
			//接入leanCloud初始化结束

			var mm = sessionStorage.getItem("分")
			console.log(parseInt(mm))
			if(parseInt(mm) < 2) {
				$(".moneyNum").html(1)
			}
			if(parseInt(mm) == 2 ||parseInt(mm) == 3||parseInt(mm) == 4) {
				$(".moneyNum").html(2)
			}
			if(parseInt(mm) >= 5) {
				$(".moneyNum").html(3)
			}
			
		payCount = 0;
			 bikeId = sessionStorage.getItem("bikeId");
			 yuan = $(".moneyNum").html();

			//			获取payCount值,查询
			var query = new AV.Query('bike_info');
			query.get(bikeId).then(function(obj) {
				var pay = obj.payCount;
				console.log(obj.attributes.payCount)
				payCount += parseInt(obj.attributes.payCount);
				payCount += parseInt(yuan);
			}, function(error) {
				// 异常处理
				console.error(error);
			});
		}
//		$(".top_fanhui").click(function() {
//			alert("请您支付后在返回！")
//		})

		$("#weixin").click(function() {
	console.log(payCount.toString())
	// 第一个参数是 className，第二个参数是 objectId，更新
			var todo = AV.Object.createWithoutData('bike_info', bikeId);
			// 修改属性
			todo.set('lastPay', yuan);
			todo.set('payCount', payCount.toString());
			todo.set('bikeState', "未使用");
			todo.set('payOr', "已结算");
			// 保存到云端
			todo.save();
			bikeHistoryUpdate ()
			alert("微信成功支付 " + yuan + " 元")
			

						$('.logoTxt').html('您已成功支付，请返回！')
			//			location.href = "index.html";
		})
		$("#zhifubao").click(function() {
			alert("支付宝成功支付 " + $(".moneyNum").html() + " 元")
			location.href = "index.html";
		})
		
		function bikeHistoryUpdate () {
			var historyId=sessionStorage.getItem("historyId")
			var bikePay =$(".moneyNum").html();
			var bikeTime =sessionStorage.getItem("时")+":"+sessionStorage.getItem("分")+":"+sessionStorage.getItem("秒");
			console.log(bikePay)
			
			var historyUpdate = AV.Object.createWithoutData('bike_history', historyId);
			// 修改属性
			historyUpdate.set('pay', bikePay);
			historyUpdate.set('bikeTime', bikeTime);
			// 保存到云端
			historyUpdate.save();
		}
		
		
	</script>

</html>